#!/bin/sh

PREFIX=$PWD/../jrtp-android-install
NDK=/home/chenc/workspace/Android/Sdk/ndk-bundle 
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/ 
PLATFORM=$NDK/platforms/android-8/arch-arm/ 
SOURCES=$NDK/sources/cxx-stl/gnu-libstdc++/4.8/
CC=$PREBUILT/bin/arm-linux-androideabi-gcc 
CXX=$PREBUILT/bin/arm-linux-androideabi-g++ 
LDFLAGS="\"--sysroot=$PLATFORM -L$SOURCES/libs/armeabi/ -lgnustl_shared -Wl,-E\"" 
CFLAGS="\"-I$PLATFORM/usr/include -I$SOURCES/include -I$SOURCES/libs/armeabi/include -fPIC -rdynamic\"" 
CXXFLAGS=$CFLAGS 
LIBS="\"-Wl,-Bstatic   -lm  -Wl,-Bdynamic\"" 

cmd="CC=$CC CXX=$CXX LDFLAGS=$LDFLAGS CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS LIBS=$LIBS  cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_INSTALL_PREFIX=$PREFIX -DJThread_DIR=$PWD/../jthread-android-install/lib/cmake/JThread/ -DJRTPLIB_USE_BIGENDIAN=OFF -DJRTPLIB_COMPILE_STATIC=ON"

eval $cmd -L .

echo ''
echo ''
echo '############'
echo 'gen Makefile'
echo '############'

eval $cmd .
